{% extends "aside/system/base.html" %}
{% load staticfiles %}
{% block custom_tdk %}
    <title>权限管理 - WanFeng</title>
    <meta name="description" content="权限管理">
{% endblock %}

{% block page-title %}权限管理{% endblock %}

{% block app-body %}

<div class="padding">
<div class="box">

<div class="row p-a">

    <div class="col-sm-6">
        <form name="searchFrom" action="" id="searchFrom">
        <div class="input-group">

                <input type="text" class="form-control" placeholder="搜索">
                <span class="input-group-btn">
                <button class="btn white" type="button"><i class="fa fa-search"></i></button>
                </span>

            </div>
        </form>
    </div>
    <div class="col-sm-6">
        <div class="row">
            <div class="col-sm-4">
                <button class="btn btn-fw dark text-white" data-toggle="modal" data-target="#modal-addPermission">添加权限</button>
            </div>
            <div class="col-sm-8">
                <select class="custom-select" id="selectPermissionGroup">
                    <option value="0">全部权限</option>
                    {% for permg in permissionGroup %}
                    <option value="{{ permg.id }}">{{ permg.name }}</option>
                    {% endfor %}
                </select>
            <button class="btn btn-sm white" data-toggle="modal" data-target="#modal-addPermissionGroup">添加权限分组</button>
            </div>
        </div>

    </div>

</div>


<div class="table-responsive">

    <table class="table table-striped table-hover b-t">
        <thead>
        <tr>
            <th style="width:20px"><label class="ui-check m-a-0">
                <input type="checkbox" id="action-toggle">
                <i></i></label></th>
            <th>权限名称</th>
            <th>权限代码</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="companyListBox">
        {% for perm in permissionData %}
        <tr>
            <td><label class="ui-check m-a-0">
                <input type="checkbox" name="post[]" value="{{ perm.id }}">
                <i class="dark-white"></i></label></td>
            <td>{{ perm.name }}</td>
            <td>{{ perm.codename }}</td>
            <td>{{ perm.description }}</td>

            <td class="text-right">
                <button class="btn btn-sm white editPermission" data-toggle="modal" data-target="#modal-editPermission" data-val="{{ perm.id }}" data-type="{{ perm.permission_type.id }}"><i class="fa fa-edit"></i> 编辑</button>
                <button class="btn btn-sm white deletePermission" data-val="{{ perm.id }}" data-toggle="modal" data-target="#modal-deletePermission"><i class="fa fa-trash"></i> 删除</button>
            </td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
</div>


<div id="modal-deletePermission" class="modal" data-backdrop="true">
    <div class="row-col h-v">
        <div class="row-cell v-m">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <form role="form" action="" method="POST">
                        {% csrf_token %}
                    <input type="hidden" name="action" value="_delete"/>
                    <input type="hidden" name="deletePermissionID" id="deletePermissionID" value="0"/>
                    <div class="modal-header">
                        <h5 class="modal-title">提示</h5>
                    </div>
                    <div class="modal-body text-center p-lg">
                        <p>您确定要删除<code id="deletePermissionName" class=""></code>?</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">否</button>
                        <button type="submit" class="btn danger p-x-md" >是</button>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<div id="modal-editPermission" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">编辑权限信息 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST">
                    {% csrf_token %}
                    <input type="hidden" name="action" value="_edit"/>
                    <input type="hidden" name="editPermissionID" id="editPermissionID" value="0"/>

                    <div class="form-group row">
                                    <label for="editPermissionName" class="col-sm-2 form-control-label">权限名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editPermissionName" name="editPermissionName" placeholder="权限名称">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="editPermissionCodeName" class="col-sm-2 form-control-label">权限代码</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="editPermissionCodeName" name="editPermissionCodeName" placeholder="权限代码">
                                    </div>
                                </div>

                    <div class="form-group row">
                        <label for="editPermissionGroup" class="col-sm-2 form-control-label">分&nbsp;&nbsp;&nbsp;&nbsp;组</label>
                        <div class="col-sm-10">
                            <select class="form-control c-select" name="editPermissionGroup" id="editPermissionGroup">
                                {% for pg in permissionGroup %}
                                <option value="{{ pg.id }}">{{ pg.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>


                    <div class="form-group row">
                        <label for="editPermissionContent" class="col-sm-2 form-control-label">内容：</label>
                        <div class="col-sm-10">
                            <textarea id="editPermissionContent" name="editPermissionContent" class="form-control" rows="4"></textarea>
                        </div>
                    </div>
                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="editBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div id="modal-addPermission" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">新增权限 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST" onsubmit="return checkform(this)">
                    {% csrf_token %}

                    <input type="hidden" name="action" value="_addPermission"/>

                    <div class="form-group row">
                        <label for="addPermissionType" class="col-sm-2 form-control-label">权限分组</label>
                        <div class="col-sm-10">
                            <select class="form-control c-select" name="addPermissionType" id="addPermissionType">
                                {% for permg in permissionGroup %}
                                <option value="{{ permg.id }}">{{ permg.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>


                    <div class="form-group row">
                                    <label for="addPermissionName" class="col-sm-2 form-control-label">权限名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="addPermissionName" name="addPermissionName" placeholder="权限名称">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="addPermissionCode" class="col-sm-2 form-control-label">权限代码</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="addPermissionCode" name="addPermissionCode" placeholder="权限代码">
                                    </div>
                                </div>

                    <div class="form-group row">
                        <label for="addPermissionContent" class="col-sm-2 form-control-label">说&nbsp;&nbsp;&nbsp;&nbsp;明</label>
                        <div class="col-sm-10">
                            <textarea id="addPermissionContent" name="addPermissionContent" class="form-control" rows="4"></textarea>
                        </div>
                    </div>
                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md" id="addBtn">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div id="modal-addPermissionGroup" class="modal black-overlay" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">新增权限分组 <a data-dismiss="modal" class="pull-right text-muted text-lg p-a-sm m-r-sm">×</a></h5>

            </div>
            <div class="modal-body text-center p-lg m-l-1 m-r-3">
                <form role="form" action="" method="POST" onsubmit="return checkform(this)">
                    {% csrf_token %}

                    <input type="hidden" name="action" value="_addPermissionGroup"/>


                    <div class="form-group row">
                                    <label for="addPermissionGroupName" class="col-sm-2 form-control-label">分组名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="addPermissionGroupName" name="addPermissionGroupName" placeholder="权限分组名称">
                                    </div>
                                </div>
                    <div class="form-group row">
                                    <label for="addPermissionGroupOrder" class="col-sm-2 form-control-label">排序</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="addPermissionGroupOrder" name="addPermissionGroupOrder" placeholder="排列序号">
                                    </div>
                                </div>
                    <div class="form-group row m-t-md">
                        <div class="col-sm-offset-2 col-sm-12">
                            <button type="button" class="btn dark-white p-x-md" data-dismiss="modal">取消</button>
                            <button type="submit" class="btn success p-x-md">提交</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<footer class="light lt p-a">

</footer>
</div>
</div>


{% endblock %}